import re
import sys
from datetime import datetime

timestamp = None
state = 0
krw = None
usdt = None

print('timestamp,price,label')

for line in sys.stdin:
  if line.startswith('* 2018'):
    timestamp = line[2:-1]
  elif line.startswith(' KRW: '):
    splitted = re.split('\ +', line)
    krw = float(splitted[2][:-1])
    usdt = float(splitted[4][:-1])
  elif line.startswith('PositionUSDT'):
    splitted = re.split('\ +', line)
    dkrw = float(splitted[4])
    dusdt = float(splitted[1])
    print('"%s",%f,"KRW"' % (timestamp, krw + dkrw))
    print('"%s",%f,"USDT"' % (timestamp, usdt + dusdt))
  elif line.startswith('MasterPrices'):
    splitted = re.split('[ ()=]+', line)
    gmean_price = float(splitted[2][:-1])
    ema_price = float(splitted[4][:-1])
    print('"%s",%f,"GMEAN_PRICE"' % (timestamp, gmean_price))
    print('"%s",%f,"EMA_PRICE"' % (timestamp, ema_price))
  elif '~' in line:
    splitted = re.split('[ ()=~]+', line)
    price1 = float(splitted[-2])
    price2 = float(splitted[-3])
    price = (price1 + price2) / 2
    ds_str = '2018 %s %s' % (splitted[0][1:], splitted[1])
    dt = datetime.strptime(ds_str, '%Y %m%d %H:%M:%S.%f')
    timestamp = dt.strftime('%Y-%m-%d %H:%M:%S.%f')
    action = splitted[5]
    print('"%s",%f,"%s"' % (timestamp, price, action))
